<template>
	<view class="map-box">
		<view class="map" v-if="markers.length">
				<map name="ssx" :markers="markers" :longitude="location.longitude" :latitude="location.latitude"></map>
		</view>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				location:'',
				markers:[]
			};
		},
		created() {
			this.getSeat()
			let _this = this;
			uni.getLocation({
				success(res) {
						_this.location = res
				},
				fail(err) {
					console.log(err);
				}
			})
		},
		methods:{
			//获取标记点位
			getSeat(){
				let _this = this;
				const url = 'https://www.fastmock.site/mock/f2f77728643567dca31e8d289b7d0f51/api/mapList'
				uni.request({
					url:url,
					method:'get',
					success(res) {
						_this.markers = res.data.data;
					
						_this.markers.forEach(item=>{
							item.iconPath = '/static/images/car.png'
						})
							console.log(_this.markers);
					}
				})
			
			}
		}
	}
</script>

<style lang="scss" scoped>
page,.map-box,.map{
	width: 100vw;
	height: 100vh;
}
map{
	height: 100%;
	width: 100%;
}
</style>
